//by qyzyq 
//wssb
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
int n, m, qwq[N], s[N];
vector<int> r[N];

struct Node 
{
	int val;
	int pe, ne;
} a[N];

int main()
{
	freopen ("fruit.in", "r", stdin);
	freopen ("fruit.out", "w", stdout);
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &qwq[i]);
		if (qwq[i] == qwq[i - 1] && i - 1) ++a[m].val;
		else a[m].ne = m + 1, a[++m].val = 1, a[m].pe = m - 1;
	}
	for (int i = 1; i <= m; i++) 
	{
		s[i] = s[i - 1] + a[i - 1].val;
		for (int j = s[i] + 1; j <= a[i].val + s[i]; j++)
			r[i].push_back (j);
	}
	a[0].pe = a[m].ne = -114514;
	int j = -1;
	while (a[0].ne > 0)
	{
		++ j;
		for (int i = a[0].ne; i > 0; i = a[i].ne)
			printf("%d ", r[i][j]);
		for (int i = a[0].ne; i > 0; i = a[i].ne)
		{
			--a[i].val;
			if (!a[i].val)
			{
				if (i == a[0].ne)
				{
					a[a[a[0].ne].ne].pe = 0;
					a[0].ne = a[a[0].ne].ne;
				}
				else
					if (a[i].ne == -114514)
						a[a[i].pe].ne = -114514;
					else
					{
						a[a[i].pe].val += a[a[i].ne].val - 1;
						for (int k = j + 1; k < r[a[i].ne].size(); k++)
							r[a[i].pe].push_back(r[a[i].ne][k]);
						a[a[a[i].ne].ne].pe = a[i].pe, // ne -> ne -> pe = pe
						a[a[i].pe].ne = a[a[i].ne].ne, // pe -> ne = ne -> ne 
						a[i].ne = a[a[i].ne].ne;
					}
			}
		}
		puts ("");
	}
	return 0;
}
